// V-backend/src/routes/products.js
const express = require('express');
const router = express.Router();
const productController = require('../controllers/productController');
const { auth } = require('../middleware/auth');  // 修复这里

// 公开路由
router.get('/', productController.getAllProducts);
router.get('/:productId', productController.getProductById);
router.get('/anchor/:anchorId', productController.getProductsByAnchor);

// 需要认证的路由
router.post('/', auth, productController.createProduct);
router.put('/:productId', auth, productController.updateProduct);
router.delete('/:productId', auth, productController.deleteProduct);
router.patch('/:productId/status', auth, productController.updateProductStatus);

module.exports = router;